package com.zc.springboot3hello.pubsub;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPubSub;

/**
 * @description:
 * @author: cong
 * @create: 2024/12/9
 */
public class RedisSubscriber extends JedisPubSub {
    @Override
    public void onMessage(String channel, String message) {
        System.out.println("channel:" + channel + " message:" + message);
    }

    public static void main(String[] args) {
        RedisSubscriber subscriber = new RedisSubscriber();
        Jedis jedis = new Jedis("127.0.0.1", 6379);
        jedis.subscribe(subscriber, "channel1");
        jedis.close();
    }
}
